<?php $this->load->view('admin_home/_header') ?>
<?php $this->load->view('message') ?>
<div class="container">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">编辑考点</h3>
		</div>
		<div class="panel-body">
			<?php echo validation_errors(); ?>
			<form id="test_point_edit_form" class="form-horizontal" action="<?php echo site_url('admin_test_point/edit')?>" method="post">
				<input type="text" id="knowledge_point_number" name="knowledge_point_number" value="1" class="hidden">
				<input type="text" id="test_point_id" name="test_point_id" value="<?=$test_point_id?>" class="hidden">
				<fieldset>
					<div class="form-group">
						<label class="col-lg-2 control-label">考点内容:</label>
						<div class="col-lg-8">
							<input class="form-control" type="text" id="content" name="content" value="<?=$test_point['content']?>"/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 control-label">相关模块:</label>
						<div class="col-lg-8">
							<select id="modules_select" class="selectpicker form-control" multiple data-live-search="true" data-style="btn-primary" multiple data-selected-text-format="count" name="relative_modules[]">
								<?php foreach ($modules as $item ): ?>
								<option value="<?=$item['id']?>">
									<?=$item['big_lecture_name']?>-><?=$item['name']?></option>
								<?php endforeach ?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 control-label">相关知识点:</label>
						<div class="col-lg-10">
							<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
								<?php $index=1; ?>
								<?php foreach ($relative_knowledge_points as $item): ?>
									<div class="panel panel-default">
									    <div class="panel-heading" role="tab" id="heading<?=$index?>">
									      <h4 class="panel-title">
									        <a data-toggle="collapse" data-parent="#accordion" href="#collapse<?=$index?>" aria-expanded="true" aria-controls="collapse<?=$index?>">
									         	<?php echo $item['content'] ?>
									        </a>
									      </h4>
									    </div>
									    <div id="collapse<?=$index?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?=$index?>">
									      <div class="panel-body">
									        	<?php if ($item['explanation']): ?>
									        		<p><?php echo $item['explanation'] ?></p>	
									        	<?php endif ?>
									        	<?php if ($item['picture']): ?>
									        		<p><img src="<?php echo base_url() ?>/uploads/exp/<?=$item['id']?>/pic.jpg?'?><?php echo rand()?>"></p>	
									        	<?php endif ?>
									      </div>
									    </div>
								  	</div>
								<?php $index++; ?>
								<?php endforeach ?>
							</div>  
							
							
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 control-label"></label>
						<div class="col-lg-8">
							<button class="btn btn-primary" type="submit">提交</button>
						</div>
					</div>
				</fieldset>
			</form> 

		</div>
	</div>
</div>

<?php $this->load->view('admin_home/_footer')?>


<script type="text/javascript">
$().ready(function(){
    $("#test_point_li").addClass("active"); 

    //JQuery验证
    $("#test_point_edit_form").validate({
					rules:{
						content:"required",
						id:"required"
					},
				});  

	// $("#knowledge_point_number").val('<?=$index?>');
	// for (var i = 1; i < <?=$index?> ; i++) {
	// 	$("#knowledge_point_input_"+i).rules("add",{required:true,maxlength:100});
	// };

	$('#modules_select').selectpicker({});

	$('#modules_select').selectpicker('val',[
	<?php foreach ($relative_modules as $item ): ?>
	<?=$item['id']?>,
	<?php endforeach ?>
			0]);

	// 	$('#knowledge_select').selectpicker('val',[
	// <?php foreach ($relative_knowledge_points as $item ): ?>
	// <?=$item['id']?>,
	// <?php endforeach ?>
	// 		0]);


});

// function add_knowledge(id)
// 	{
// 		if($("#knowledge_point_input_"+id).val()=="")
// 		{
// 			alert("添加时不能为空");
// 		}
// 		else
// 		{
// 			$("#knowledge_point_button_"+id).text("删除");
// 			$("#knowledge_point_button_"+id).attr("onclick","delete_knowledge("+id+")");
// 			nextId=id+1;
// 			html="<div class='row' id='knowledge_point_row_"+nextId+"'>"+
// 								"<div class='col-lg-7'>"+
// 									"<input type='text' class='form-control' name='knowledge_point_input_"+nextId+"' id='knowledge_point_input_"+nextId+"'></div>"+
// 								"<div class='col-lg-4'>"+
// 									"<a class='btn btn-primary' id='knowledge_point_button_"+nextId+"' onclick='add_knowledge("+nextId+")'>添加</a>"+
// 								"</div>"+
// 							"</div>";
// 			$("#knowledge_point_row_"+id).after(html);
// 			$("#knowledge_point_number").val(nextId);
// 			$("#knowledge_point_input_"+id).rules("add",{required:true,maxlength:100});
// 		}
// 	}

// 	function delete_knowledge(id)
// 	{
// 		$("#knowledge_point_row_"+id).remove();
// 		$("#knowledge_point_input_"+id).rules("remove");
// 	}
	
</script>